package com.heeexy.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.heeexy.example.dao.EmpsDao;
import com.heeexy.example.dao.GoodsDao;
import com.heeexy.example.service.EmpsService;
import com.heeexy.example.util.CommonUtil;

@Service
public class EmpsServiceImpl implements EmpsService{
	
	@Autowired
    private EmpsDao empsDao;

	@Override
	public JSONObject listEmps(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = empsDao.countEmps(jsonObject);
        List<JSONObject> list =  empsDao.listEmps(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	 @Override
	 @Transactional(rollbackFor = Exception.class)
	public JSONObject updateEmps(JSONObject jsonObject) {
		 empsDao.updateEmps(jsonObject);
	     return CommonUtil.successJson();
	}

	 @Override
	 @Transactional(rollbackFor = Exception.class)
	public JSONObject addEmps(JSONObject jsonObject) {
		 empsDao.addEmps(jsonObject);
	     return CommonUtil.successJson();
	}

	 @Transactional(rollbackFor = Exception.class)
    @SuppressWarnings("unchecked")
    @Override
	public JSONObject deleteEmps(JSONObject jsonObject) {
		 empsDao.deleteEmps(jsonObject);
	        return CommonUtil.successJson();
	}

}
